package com.hcmu.common;

import android.R;
import android.R.anim;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.Toast;

public class SpinnerSetting implements OnItemSelectedListener{
	private Context mContext;
	Spinner spinner;
	
	public SpinnerSetting(Context context) {
		this.mContext = context;
		initSpinner();
	}
	
	
	public void show(){
		ArrayAdapter<?> adapter = ArrayAdapter.createFromResource(mContext, com.hcmu.R.array.setting_font_text, android.R.layout.simple_spinner_dropdown_item);
		adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
		spinner.setAdapter(adapter);
		spinner.setOnItemSelectedListener(new OnItemSelectedListener() {

			@Override
			public void onItemSelected(AdapterView<?> parent, View v,
					int position, long id) {
				// On selecting a spinner item
		        String item = parent.getItemAtPosition(position).toString();
		        
		        // showing a toast on selecting an item 
		        Toast.makeText(parent.getContext(), item, Toast.LENGTH_LONG).show();
			}
			

			@Override
			public void onNothingSelected(AdapterView<?> parent) {
				// TODO Auto-generated method stub
				
			}
		});
	}
	
	
	
	private void initSpinner() {
		LayoutInflater lf = LayoutInflater.from(mContext);
		View app = lf.inflate(com.hcmu.R.layout.simple_spinner, null);
		
		spinner = (Spinner) app.findViewById(com.hcmu.R.id.spinnerDefault);
		
		
	}




	@Override
	public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2,
			long arg3) {
		// TODO Auto-generated method stub
		
	}

	@Override
	public void onNothingSelected(AdapterView<?> arg0) {
		// TODO Auto-generated method stub
		
	}

}
